

package io.renren.modules.job.task.clear;

import io.renren.modules.clearing.service.ETCTransactionDownService;
import io.renren.modules.job.task.ITask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 测试定时任务(演示Demo，可删除)
 *
 * testTask为spring bean的名称
 *
 * @author Mark sunlightcs@gmail.com
 */
@Component("etcTransactionDownTask")
public class ETCTransactionDownTask implements ITask {
	private Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	ETCTransactionDownService etcTransactionDownService;


	@Override
	public void run(String params){

		logger.info("etcTransactionDownTask 定时任务正在执行，参数为：{}", params);

		try {
			String[] versions = etcTransactionDownService.ETCTransactionDown();

			if(versions!=null&&versions.length>0){
				for (int i = 0; i < versions.length; i++) {
					try {
						etcTransactionDownService.DownloadFile(versions[i],1);
					} catch (Exception e) {
						e.printStackTrace();

						logger.info("任务异常");
					}
				}

			}else{
				logger.info("任务暂停，或是没有待处理的版本");
			}
		}catch (Exception e){
			e.printStackTrace();
		}
	}
}
